

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>局部自修复纠删码插件 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex/" />
    <link rel="search" title="Search" href="../../../search/" />
    <link rel="next" title="SHEC 纠删码插件" href="../erasure-code-shec/" />
    <link rel="prev" title="ISA 纠删码插件" href="../erasure-code-isa/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../">Ceph 存储集群</a></li>
          <li class="breadcrumb-item"><a href="../">集群运维</a></li>
          <li class="breadcrumb-item"><a href="../erasure-code/">纠删码</a></li>
          <li class="breadcrumb-item"><a href="../erasure-code-profile/">纠删码配置</a></li>
      <li class="breadcrumb-item active">局部自修复纠删码插件</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../../_sources/rados/operations/erasure-code-lrc.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephadm/">Cephadm</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../">Ceph 存储集群</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../configuration/">配置</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../">运维</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../operating/">操纵集群</a></li>
<li class="toctree-l3"><a class="reference internal" href="../health-checks/">健康检查</a></li>
<li class="toctree-l3"><a class="reference internal" href="../monitoring/">监控集群</a></li>
<li class="toctree-l3"><a class="reference internal" href="../monitoring-osd-pg/">监控 OSD 和归置组</a></li>
<li class="toctree-l3"><a class="reference internal" href="../user-management/">用户管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../pgcalc/">PG Calc</a></li>
<li class="toctree-l3"><a class="reference internal" href="../data-placement/">数据归置概览</a></li>
<li class="toctree-l3"><a class="reference internal" href="../pools/">存储池</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="../erasure-code/">纠删码</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../erasure-code/#id2">创建纠删码存储池样板</a></li>
<li class="toctree-l4"><a class="reference internal" href="../erasure-code/#id3">纠删码配置</a></li>
<li class="toctree-l4"><a class="reference internal" href="../erasure-code/#id4">在纠删码存储池上启用重写功能</a></li>
<li class="toctree-l4"><a class="reference internal" href="../erasure-code/#erasure-coded-pool-overhead">Erasure-coded pool overhead</a></li>
<li class="toctree-l4"><a class="reference internal" href="../erasure-code/#id6">纠删码存储池与缓存分级</a></li>
<li class="toctree-l4"><a class="reference internal" href="../erasure-code/#id9">纠删码存储池的恢复</a></li>
<li class="toctree-l4"><a class="reference internal" href="../erasure-code/#id10">术语</a></li>
<li class="toctree-l4 current"><a class="reference internal" href="../erasure-code/#id11">内容列表</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../cache-tiering/">分级缓存</a></li>
<li class="toctree-l3"><a class="reference internal" href="../placement-groups/">归置组</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upmap/">使用 pg-upmap</a></li>
<li class="toctree-l3"><a class="reference internal" href="../read-balancer/">Operating the Read (Primary) Balancer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../balancer/">均衡器模块</a></li>
<li class="toctree-l3"><a class="reference internal" href="../crush-map/">CRUSH 图</a></li>
<li class="toctree-l3"><a class="reference internal" href="../crush-map-edits/">手动编辑一个 CRUSH 图</a></li>
<li class="toctree-l3"><a class="reference internal" href="../stretch-mode/">Stretch Clusters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../change-mon-elections/">Configuring Monitor Election Strategies</a></li>
<li class="toctree-l3"><a class="reference internal" href="../add-or-rm-osds/">增加/删除 OSD</a></li>
<li class="toctree-l3"><a class="reference internal" href="../add-or-rm-mons/">增加/删除监视器</a></li>
<li class="toctree-l3"><a class="reference internal" href="../devices/">设备管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../bluestore-migration/">迁移到 BlueStore</a></li>
<li class="toctree-l3"><a class="reference internal" href="../control/">命令参考</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../troubleshooting/community/">Ceph 社区</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../troubleshooting/troubleshooting-mon/">监视器故障排除</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../troubleshooting/troubleshooting-osd/">OSD 故障排除</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../troubleshooting/troubleshooting-pg/">归置组排障</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../troubleshooting/log-and-debug/">日志记录和调试</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../troubleshooting/cpu-profiling/">CPU 剖析</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../troubleshooting/memory-profiling/">内存剖析</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../man/">    手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../troubleshooting/">故障排除</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../api/">APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="id1">
<h1>局部自修复纠删码插件<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h1>
<p>用 <em>jerasure</em> 插件时，纠删码编码的对象存储在多个 OSD 上，丢失一个 OSD 的恢复过程需读取所有其他的 OSD 。比如 <em>jerasure</em> 的配置为 <em>k=8</em> 且 <em>m=4</em> ，丢失一个 OSD 后需读取其它 8 个 OSD
才能恢复。</p>
<p><em>lrc</em> 纠删码插件创建的是局部校验块，这样只需较少的 OSD 即可恢复。比如 <em>lrc</em> 的配置为 <em>k=8</em> 、 <em>m=4</em> 且 <em>l=4</em> ，它将为每四个 OSD 创建额外的校验块，当一个 OSD 丢失时，它只需四个 OSD
即可恢复，而不需要八个。</p>
<section id="id2">
<h2>纠删码配置实例<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<section id="id3">
<h3>降低主机间的恢复带宽<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h3>
<p>虽然当所有主机都接入同一交换机时，这不会是诱人的用法，但是带宽利用率确实降低了。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "$ ";
}
</style><span class="prompt1">ceph<span class="w"> </span>osd<span class="w"> </span>erasure-code-profile<span class="w"> </span><span class="nb">set</span><span class="w"> </span>LRCprofile<span class="w"> </span><span class="se">\</span>
<span class="w">   </span><span class="nv">plugin</span><span class="o">=</span>lrc<span class="w"> </span><span class="se">\</span>
<span class="w">   </span><span class="nv">k</span><span class="o">=</span><span class="m">4</span><span class="w"> </span><span class="nv">m</span><span class="o">=</span><span class="m">2</span><span class="w"> </span><span class="nv">l</span><span class="o">=</span><span class="m">3</span><span class="w"> </span><span class="se">\</span>
<span class="w">   </span>crush-failure-domain<span class="o">=</span>host</span>
<span class="prompt1">ceph<span class="w"> </span>osd<span class="w"> </span>pool<span class="w"> </span>create<span class="w"> </span>lrcpool<span class="w"> </span>erasure<span class="w"> </span>LRCprofile</span>
</pre></div></div></section>
<section id="id4">
<h3>降低机架间的恢复带宽<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h3>
<p>在 Firefly 版中，只有主 OSD 与丢失块位于同一机架时所需带宽才能降低。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>osd<span class="w"> </span>erasure-code-profile<span class="w"> </span><span class="nb">set</span><span class="w"> </span>LRCprofile<span class="w"> </span><span class="se">\</span>
<span class="w">   </span><span class="nv">plugin</span><span class="o">=</span>lrc<span class="w"> </span><span class="se">\</span>
<span class="w">   </span><span class="nv">k</span><span class="o">=</span><span class="m">4</span><span class="w"> </span><span class="nv">m</span><span class="o">=</span><span class="m">2</span><span class="w"> </span><span class="nv">l</span><span class="o">=</span><span class="m">3</span><span class="w"> </span><span class="se">\</span>
<span class="w">   </span>crush-locality<span class="o">=</span>rack<span class="w"> </span><span class="se">\</span>
<span class="w">   </span>crush-failure-domain<span class="o">=</span>host</span>
<span class="prompt1">ceph<span class="w"> </span>osd<span class="w"> </span>pool<span class="w"> </span>create<span class="w"> </span>lrcpool<span class="w"> </span>erasure<span class="w"> </span>LRCprofile</span>
</pre></div></div></section>
</section>
<section id="lrc">
<h2>创建 lrc 配置<a class="headerlink" href="#lrc" title="Permalink to this heading"></a></h2>
<p>要新建 <em>lrc</em> 纠删码配置：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>osd<span class="w"> </span>erasure-code-profile<span class="w"> </span><span class="nb">set</span><span class="w"> </span><span class="o">{</span>name<span class="o">}</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span><span class="nv">plugin</span><span class="o">=</span>lrc<span class="w"> </span><span class="se">\</span>
<span class="w">    </span><span class="nv">k</span><span class="o">={</span>data-chunks<span class="o">}</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span><span class="nv">m</span><span class="o">={</span>coding-chunks<span class="o">}</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span><span class="nv">l</span><span class="o">={</span>locality<span class="o">}</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span><span class="o">[</span>crush-root<span class="o">={</span>root<span class="o">}]</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span><span class="o">[</span>crush-locality<span class="o">={</span>bucket-type<span class="o">}]</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span><span class="o">[</span>crush-failure-domain<span class="o">={</span>bucket-type<span class="o">}]</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span><span class="o">[</span>crush-device-class<span class="o">={</span>device-class<span class="o">}]</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span><span class="o">[</span><span class="nv">directory</span><span class="o">={</span>directory<span class="o">}]</span><span class="w"> </span><span class="se">\</span>
<span class="w">    </span><span class="o">[</span>--force<span class="o">]</span></span>
</pre></div></div><p>其中：</p>
<p><code class="docutils literal notranslate"><span class="pre">k={data</span> <span class="pre">chunks}</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">描述<span class="colon">:</span></dt>
<dd class="field-odd"><p>各对象都被分割为<strong>数据块</strong>，分别存储于不同 OSD 。</p>
</dd>
<dt class="field-even">类型<span class="colon">:</span></dt>
<dd class="field-even"><p>Integer</p>
</dd>
<dt class="field-odd">是否必需<span class="colon">:</span></dt>
<dd class="field-odd"><p>Yes.</p>
</dd>
<dt class="field-even">实例<span class="colon">:</span></dt>
<dd class="field-even"><p>4</p>
</dd>
</dl>
<p><code class="docutils literal notranslate"><span class="pre">m={coding-chunks}</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">描述<span class="colon">:</span></dt>
<dd class="field-odd"><p>计算各对象的<strong>编码块</strong>、并存储于不同 OSD 。编码块的数量等同于在不丢数据的前提下允许同时失效的 OSD 数量。</p>
</dd>
<dt class="field-even">类型<span class="colon">:</span></dt>
<dd class="field-even"><p>Integer</p>
</dd>
<dt class="field-odd">是否必需<span class="colon">:</span></dt>
<dd class="field-odd"><p>Yes.</p>
</dd>
<dt class="field-even">实例<span class="colon">:</span></dt>
<dd class="field-even"><p>2</p>
</dd>
</dl>
<p><code class="docutils literal notranslate"><span class="pre">l={locality}</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">描述<span class="colon">:</span></dt>
<dd class="field-odd"><p>把编码块和数据块分组为大小为 <strong>locality</strong> 的集合。比如，
<strong>k=4</strong> 且 <strong>m=2</strong> 时，若设置 <strong>locality=3</strong> ，将会分组为大小为三的两组，这样各组都能自行恢复，无需从另一组读数据块。</p>
</dd>
<dt class="field-even">类型<span class="colon">:</span></dt>
<dd class="field-even"><p>Integer</p>
</dd>
<dt class="field-odd">是否必需<span class="colon">:</span></dt>
<dd class="field-odd"><p>Yes.</p>
</dd>
<dt class="field-even">实例<span class="colon">:</span></dt>
<dd class="field-even"><p>3</p>
</dd>
</dl>
<p><code class="docutils literal notranslate"><span class="pre">crush-root={root}</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">描述<span class="colon">:</span></dt>
<dd class="field-odd"><p>CRUSH 规则第一步所指向的 CRUSH 桶之名，如
<strong>step take default</strong> 。</p>
</dd>
<dt class="field-even">类型<span class="colon">:</span></dt>
<dd class="field-even"><p>String</p>
</dd>
<dt class="field-odd">是否必需<span class="colon">:</span></dt>
<dd class="field-odd"><p>No.</p>
</dd>
<dt class="field-even">默认值<span class="colon">:</span></dt>
<dd class="field-even"><p>default</p>
</dd>
</dl>
<p><code class="docutils literal notranslate"><span class="pre">crush-locality={bucket-type}</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">描述<span class="colon">:</span></dt>
<dd class="field-odd"><p>由 <strong>l</strong> 定义的块集合将按哪种 crush 桶类型存储。比如，若设置为 <strong>rack</strong> ，大小为 <strong>l</strong> 块的各组将被存入不同的机架，此值会被用于创建类似 <strong>step choose rack</strong> 的CRUSH 规则。如果没设置，就不会这样分组。</p>
</dd>
<dt class="field-even">类型<span class="colon">:</span></dt>
<dd class="field-even"><p>String</p>
</dd>
<dt class="field-odd">是否必需<span class="colon">:</span></dt>
<dd class="field-odd"><p>No.</p>
</dd>
</dl>
<p><code class="docutils literal notranslate"><span class="pre">crush-failure-domain={bucket-type}</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">描述<span class="colon">:</span></dt>
<dd class="field-odd"><p>确保两个编码块不会存在于同一故障域的桶里面。比如，假设故障域是 <strong>host</strong> ，就不会有两个编码块存储到同一主机；此值用于在 CRUSH 规则中创建类似 <strong>step chooseleaf host</strong>
的步骤。</p>
</dd>
<dt class="field-even">类型<span class="colon">:</span></dt>
<dd class="field-even"><p>String</p>
</dd>
<dt class="field-odd">是否必需<span class="colon">:</span></dt>
<dd class="field-odd"><p>No.</p>
</dd>
<dt class="field-even">默认值<span class="colon">:</span></dt>
<dd class="field-even"><p>host</p>
</dd>
</dl>
<p><code class="docutils literal notranslate"><span class="pre">crush-device-class={device-class}</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">描述<span class="colon">:</span></dt>
<dd class="field-odd"><p>使归置限于指定的设备类（比如 <code class="docutils literal notranslate"><span class="pre">ssd</span></code> 或 <code class="docutils literal notranslate"><span class="pre">hdd</span></code> ）之内，在 CRUSH 图内用的是 crush 设备类的名字。</p>
</dd>
<dt class="field-even">类型<span class="colon">:</span></dt>
<dd class="field-even"><p>String</p>
</dd>
<dt class="field-odd">是否必需<span class="colon">:</span></dt>
<dd class="field-odd"><p>No.</p>
</dd>
</dl>
<p><code class="docutils literal notranslate"><span class="pre">directory={directory}</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">描述<span class="colon">:</span></dt>
<dd class="field-odd"><p>设置纠删码插件的路径，需是<strong>目录</strong>。</p>
</dd>
<dt class="field-even">类型<span class="colon">:</span></dt>
<dd class="field-even"><p>String</p>
</dd>
<dt class="field-odd">是否必需<span class="colon">:</span></dt>
<dd class="field-odd"><p>No.</p>
</dd>
<dt class="field-even">默认值<span class="colon">:</span></dt>
<dd class="field-even"><p>/usr/lib/ceph/erasure-code</p>
</dd>
</dl>
<p><code class="docutils literal notranslate"><span class="pre">--force</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">描述<span class="colon">:</span></dt>
<dd class="field-odd"><p>覆盖同名配置。</p>
</dd>
<dt class="field-even">类型<span class="colon">:</span></dt>
<dd class="field-even"><p>String</p>
</dd>
<dt class="field-odd">是否必需<span class="colon">:</span></dt>
<dd class="field-odd"><p>No.</p>
</dd>
</dl>
</section>
<section id="id5">
<h2>低级插件配置<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h2>
<p><strong>k</strong> 与 <strong>m</strong> 之和必须是 <strong>l</strong> 参数的整数倍。
低级配置参数没有强加这样的限制，
并且在某些场合下更有益。因此有可能配置两个组，一组 4 块、另一组 3 块；也有可能递归地定义局部集合，
如数据中心和机架再组合为数据中心。
<strong>k/m/l</strong> 可通过生成低级配置来实现。</p>
<p><em>lrc</em> 纠删码插件递归地使用纠删码技术，
这样一些块丢失的恢复大多只需少部分数据块的子集。</p>
<p>比如，三步编码描述为如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">chunk</span> <span class="n">nr</span>    <span class="mi">01234567</span>
<span class="n">step</span> <span class="mi">1</span>      <span class="n">_cDD_cDD</span>
<span class="n">step</span> <span class="mi">2</span>      <span class="n">cDDD____</span>
<span class="n">step</span> <span class="mi">3</span>      <span class="n">____cDDD</span>
</pre></div>
</div>
<p>其中， <em>c</em> 是从数据块 <em>D</em> 计算出的编码块，
块 <em>7</em> 丢失后能从后四个块恢复，
块 <em>2</em> 丢失后能从前四个块恢复。</p>
</section>
<section id="id6">
<h2>使用低级配置的纠删码配置实例<a class="headerlink" href="#id6" title="Permalink to this heading"></a></h2>
<section id="id7">
<h3>最小测试<a class="headerlink" href="#id7" title="Permalink to this heading"></a></h3>
<p>此例其实完全等价于 <em>K=2</em> <em>M=1</em> 纠删码配置， <em>DD</em> 其实就是
<em>K=2</em> 、 <em>c</em> 就是 <em>M=1</em> 并且默认使用 <em>lrc</em> 插件：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>osd<span class="w"> </span>erasure-code-profile<span class="w"> </span><span class="nb">set</span><span class="w"> </span>LRCprofile<span class="w"> </span><span class="se">\</span>
<span class="w">   </span><span class="nv">plugin</span><span class="o">=</span>lrc<span class="w"> </span><span class="se">\</span>
<span class="w">   </span><span class="nv">mapping</span><span class="o">=</span>DD_<span class="w"> </span><span class="se">\</span>
<span class="w">   </span><span class="nv">layers</span><span class="o">=</span><span class="s1">&#39;[ [ &quot;DDc&quot;, &quot;&quot; ] ]&#39;</span></span>
<span class="prompt1">ceph<span class="w"> </span>osd<span class="w"> </span>pool<span class="w"> </span>create<span class="w"> </span>lrcpool<span class="w"> </span>erasure<span class="w"> </span>LRCprofile</span>
</pre></div></div></section>
<section id="id8">
<h3>降低主机间的恢复带宽<a class="headerlink" href="#id8" title="Permalink to this heading"></a></h3>
<p>虽然当所有主机都接入同一交换机时，这不会是诱人的用法，但是带宽利用率确实降低了。它等价于 <strong>k=4</strong> 、 <strong>m=2</strong> 且 <strong>l=3</strong> ，尽管数据块的布局不同。 <strong>警告：提示符是可选的</strong></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ceph osd erasure-code-profile set LRCprofile \
     plugin=lrc \
     mapping=__DD__DD \
     layers=&#39;[
               [ &quot;_cDD_cDD&quot;, &quot;&quot; ],
               [ &quot;cDDD____&quot;, &quot;&quot; ],
               [ &quot;____cDDD&quot;, &quot;&quot; ],
             ]&#39;
$ ceph osd pool create lrcpool erasure LRCprofile
</pre></div>
</div>
</section>
<section id="id9">
<h3>降低机架间的恢复带宽<a class="headerlink" href="#id9" title="Permalink to this heading"></a></h3>
<p>在 Firefly 版中，只有主 OSD 与丢失块位于同一机架时所需带宽才能降低。 <strong>警告：提示符是可选的</strong></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ceph osd erasure-code-profile set LRCprofile \
    plugin=lrc \
    mapping=__DD__DD \
    layers=&#39;[
              [ &quot;_cDD_cDD&quot;, &quot;&quot; ],
              [ &quot;cDDD____&quot;, &quot;&quot; ],
              [ &quot;____cDDD&quot;, &quot;&quot; ],
            ]&#39; \
    crush-steps=&#39;[
                    [ &quot;choose&quot;, &quot;rack&quot;, 2 ],
                    [ &quot;chooseleaf&quot;, &quot;host&quot;, 4 ],
                   ]&#39;

$ ceph osd pool create lrcpool erasure LRCprofile
</pre></div>
</div>
</section>
<section id="id10">
<h3>不同纠删码后端测试<a class="headerlink" href="#id10" title="Permalink to this heading"></a></h3>
<p>LRC 当前用 jerasure 作为默认 EC 后端。使用低级配置时，你可以为每一级分别指定 EC 后端、算法。 layers=’[ [ “DDc”, “” ] ]’ 里的第二个参数其实是用于本级的纠删码配置。下面的例子为
lrcpool 存储池配置了 cauchy 技术的 ISA 后端。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>osd<span class="w"> </span>erasure-code-profile<span class="w"> </span><span class="nb">set</span><span class="w"> </span>LRCprofile<span class="w"> </span><span class="se">\</span>
<span class="w">   </span><span class="nv">plugin</span><span class="o">=</span>lrc<span class="w"> </span><span class="se">\</span>
<span class="w">   </span><span class="nv">mapping</span><span class="o">=</span>DD_<span class="w"> </span><span class="se">\</span>
<span class="w">   </span><span class="nv">layers</span><span class="o">=</span><span class="s1">&#39;[ [ &quot;DDc&quot;, &quot;plugin=jerasure technique=cauchy&quot; ] ]&#39;</span></span>
<span class="prompt1">ceph<span class="w"> </span>osd<span class="w"> </span>pool<span class="w"> </span>create<span class="w"> </span>lrcpool<span class="w"> </span>erasure<span class="w"> </span>LRCprofile</span>
</pre></div></div><p>你也可以为各级分别使用不同的纠删码配置。 <strong>警告：提示符是可选的</strong></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ceph osd erasure-code-profile set LRCprofile \
     plugin=lrc \
     mapping=__DD__DD \
     layers=&#39;[
               [ &quot;_cDD_cDD&quot;, &quot;plugin=isa technique=cauchy&quot; ],
               [ &quot;cDDD____&quot;, &quot;plugin=isa&quot; ],
               [ &quot;____cDDD&quot;, &quot;plugin=jerasure&quot; ],
             ]&#39;
$ ceph osd pool create lrcpool erasure LRCprofile
</pre></div>
</div>
</section>
</section>
<section id="id11">
<h2>纠删编码和解码算法<a class="headerlink" href="#id11" title="Permalink to this heading"></a></h2>
<p>在层描述中找出的步骤：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">chunk</span> <span class="n">nr</span>    <span class="mi">01234567</span>

<span class="n">step</span> <span class="mi">1</span>      <span class="n">_cDD_cDD</span>
<span class="n">step</span> <span class="mi">2</span>      <span class="n">cDDD____</span>
<span class="n">step</span> <span class="mi">3</span>      <span class="n">____cDDD</span>
</pre></div>
</div>
<p>将被依次应用。比如一个 4K 的对象要被编码，
它要先通过 <strong>step 1</strong> 被分割为四个 1K 的块（四个大写的 D ），
分别依次存储于 2 、 3 、 6 和 7 。
这些数据产生了两个编码块（两个小写 c ），
它们分别存储于 1 和 5 。</p>
<p><em>step 2</em> 以相似的方式重用 <em>step 1</em> 创建的内容，
并把单个编码块 <em>c</em> 存储于位置 0 。
最后四个下划线（ <em>_</em> ）标记是为提高可读性的，被忽略了。</p>
<p><em>step 3</em> 把单个编码块存储到了位置 4 ，
<em>step 1</em> 创建的三个块被用于计算此编码块，
也就是 <em>step 1</em> 产生的编码块成了 <em>step 3</em> 的数据块。</p>
<p>如果 <em>2</em> 块丢失了：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">chunk</span> <span class="n">nr</span>    <span class="mi">01234567</span>

<span class="n">step</span> <span class="mi">1</span>      <span class="n">_c</span> <span class="n">D_cDD</span>
<span class="n">step</span> <span class="mi">2</span>      <span class="n">cD</span> <span class="n">D____</span>
<span class="n">step</span> <span class="mi">3</span>      <span class="n">__</span> <span class="n">_cDDD</span>
</pre></div>
</div>
<p>将通过解码来恢复它，反向依次执行：
<em>step 3</em> 然后 <em>step 2</em> 最后是 <em>step 1</em> 。</p>
<p><em>step 3</em> 对 <em>2</em> 一无所知（即它是下划线），所以跳过此步。</p>
<p><em>step 2</em> 里的编码块存储在 <em>0</em> 块中，
可用来恢复 <em>2</em> 块的内容。没有需要恢复的数据块了，不再考虑 <em>step 1</em> ，进程终止。</p>
<p>恢复块 <em>2</em> 需读取块 <em>0, 1, 3</em>
并写回块 <em>2</em> 。</p>
<p>如果块 <em>2, 3, 6</em> 丢失：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">chunk</span> <span class="n">nr</span>    <span class="mi">01234567</span>

<span class="n">step</span> <span class="mi">1</span>      <span class="n">_c</span>  <span class="n">_c</span> <span class="n">D</span>
<span class="n">step</span> <span class="mi">2</span>      <span class="n">cD</span>  <span class="n">__</span> <span class="n">_</span>
<span class="n">step</span> <span class="mi">3</span>      <span class="n">__</span>  <span class="n">cD</span> <span class="n">D</span>
</pre></div>
</div>
<p><em>step 3</em> 可恢复块 <em>6</em> 的内容：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">chunk</span> <span class="n">nr</span>    <span class="mi">01234567</span>

<span class="n">step</span> <span class="mi">1</span>      <span class="n">_c</span>  <span class="n">_cDD</span>
<span class="n">step</span> <span class="mi">2</span>      <span class="n">cD</span>  <span class="n">____</span>
<span class="n">step</span> <span class="mi">3</span>      <span class="n">__</span>  <span class="n">cDDD</span>
</pre></div>
</div>
<p><em>step 2</em> 未能恢复被跳过了，
因为丢失了两块（ <em>2, 3</em> ），
它只能恢复一个块的丢失。</p>
<p><em>step 1</em> 中的编码块位于块 <em>1, 5</em> ，
因此能恢复块 <em>2, 3</em> 的内容。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">chunk</span> <span class="n">nr</span>    <span class="mi">01234567</span>

<span class="n">step</span> <span class="mi">1</span>      <span class="n">_cDD_cDD</span>
<span class="n">step</span> <span class="mi">2</span>      <span class="n">cDDD____</span>
<span class="n">step</span> <span class="mi">3</span>      <span class="n">____cDDD</span>
</pre></div>
</div>
</section>
<section id="crush">
<h2>CRUSH 归置的控制<a class="headerlink" href="#crush" title="Permalink to this heading"></a></h2>
<p>默认的 CRUSH 规则会选择位于不同主机的 OSD ，例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">chunk</span> <span class="n">nr</span>    <span class="mi">01234567</span>

<span class="n">step</span> <span class="mi">1</span>      <span class="n">_cDD_cDD</span>
<span class="n">step</span> <span class="mi">2</span>      <span class="n">cDDD____</span>
<span class="n">step</span> <span class="mi">3</span>      <span class="n">____cDDD</span>
</pre></div>
</div>
<p>需要整整 8 个 OSD ，分别存储 8 个块。
如果这些主机分别位于相邻的机架，
前四块可放到第一个机架，后四块可放到第二个机架，
这样丢失单个 OSD 恢复时就不会用到机架间的带宽。</p>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">crush</span><span class="o">-</span><span class="n">steps</span><span class="o">=</span><span class="s1">&#39;[ [ &quot;choose&quot;, &quot;rack&quot;, 2 ], [ &quot;chooseleaf&quot;, &quot;host&quot;, 4 ] ]&#39;</span>
</pre></div>
</div>
<p>此配置会创建这样的规则，选定类型为 <em>rack</em> 的两个 crush 桶、并在各桶中再选四个 OSD ，这几个 OSD 分别位于类型为 <em>host</em> 的不同桶中。</p>
<p>此 CRUSH 规则还可以手工雕琢一下，使其更精细。</p>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../erasure-code-isa/" class="btn btn-neutral float-left" title="ISA 纠删码插件" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../erasure-code-shec/" class="btn btn-neutral float-right" title="SHEC 纠删码插件" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>